Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[securityAssistant] LangGraph ES|QL query generation tool #186489

Closed

Conversation

patrykkopycinski
Copy link
Contributor

@patrykkopycinski patrykkopycinski commented Jun 19, 2024

Important

Upping cloud deploy ML memory for ELSER and enabling eval FF. Must revert 45e586b before merging!

Summary

Adds LangGraph-based ESQL generation tool that was heavily inspired by Observability AI Assistant query function

Currently functionality is hidden behind FF:
xpack.securitySolution.enableExperimental=['aiAssistantGraphEsqlTool']

This tool relies also on Knowledge base to be enabled.

To test Cases changes feel free to just post a comment like:

```esql
FROM logs-*
| STATS count = COUNT(*) BY host.name
| SORT count DESC
| LIMIT 10

(make sure to close esql tag, because github formatting didn't allow me to do so)

image
esql.generation.1.mp4

spong and others added 23 commits May 30, 2024 17:23
…raph

# Conflicts:
#	x-pack/plugins/observability_solution/observability_ai_assistant_app/public/functions/visualize_esql.tsx
…raph

# Conflicts:
#	package.json
#	x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/graph.ts
#	x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.ts
#	x-pack/plugins/search_playground/server/lib/conversational_chain.test.ts
#	x-pack/test/security_solution_cypress/config.ts
#	yarn.lock
@patrykkopycinski patrykkopycinski added the ci:cloud-deploy Create or update a Cloud deployment label Jun 20, 2024
@patrykkopycinski
Copy link
Contributor Author

/ci

@patrykkopycinski
Copy link
Contributor Author

/ci

@kibana-ci
Copy link
Collaborator

kibana-ci commented Jul 1, 2024

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Defend Workflows Cypress Tests #19 / When accessing Endpoint Response Console from Cases "before all" hook for "should display responder option in take action menu" "before all" hook for "should display responder option in take action menu"

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 5578 5579 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/elastic-assistant 139 141 +2
elasticAssistant 34 39 +5
total +7

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cases 479.4KB 479.8KB +400.0B
securitySolution 15.5MB 15.6MB +20.8KB
total +21.2KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
elasticAssistant 1 2 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 83.6KB 83.8KB +171.0B
Unknown metric groups

API count

id before after diff
@kbn/elastic-assistant 166 168 +2
elasticAssistant 48 53 +5
total +7

async chunk count

id before after diff
securitySolution 101 102 +1

ESLint disabled in files

id before after diff
elasticAssistant 0 1 +1

ESLint disabled line counts

id before after diff
securitySolution 551 554 +3

Total ESLint disabled count

id before after diff
elasticAssistant 49 50 +1
securitySolution 634 637 +3
total +4

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @patrykkopycinski

@patrykkopycinski patrykkopycinski changed the title Feat/esql langgraph [securityAssistant] LangGraph ES|QL query generation tool Jul 2, 2024
@patrykkopycinski patrykkopycinski self-assigned this Jul 2, 2024
@patrykkopycinski patrykkopycinski marked this pull request as ready for review July 2, 2024 00:03
@patrykkopycinski patrykkopycinski requested review from a team as code owners July 2, 2024 00:03
Copy link
Contributor

@peluja1012 peluja1012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We plan to discuss moving common esql validation code before merging.

…raph

# Conflicts:
#	x-pack/plugins/elastic_assistant/server/lib/langchain/execute_custom_llm_chain/index.ts
#	x-pack/plugins/elastic_assistant/server/lib/langchain/executors/types.ts
#	x-pack/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/index.ts
#	x-pack/plugins/elastic_assistant/server/routes/post_actions_connector_execute.test.ts
#	x-pack/plugins/elastic_assistant/server/routes/post_actions_connector_execute.ts
Copy link
Member

@joemcelroy joemcelroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed Playground changes and working fine. the test updates look fine too.

Copy link
Contributor

@angorayc angorayc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the enhancement @patrykkopycinski 👍 👍 👍
I enabled the knowledge base and preview the case, but still had an error. Could you please check if you can reproduce this?

Screen.Recording.2024-07-04.at.17.22.49.mov

</EuiCodeBlock>
</EuiFlexItem>

{!showVisualization && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it relies on knowledge base to work, should we check if the knowledge base toggle is on here?
Screenshot 2024-07-04 at 17 23 52

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @angorayc, the UI part doesn't need Knowledge base to be enabled, but it requires in your case to packetbeat-* to exists and have proper data propagated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can confirm that I have packetbeat-* data. I searched the same ESQL within timeline, and there was one entry appeared in the table, but it wasn't able to be visualised from the case markdown when using preview.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will double check, Thank you 🙇

@peluja1012 peluja1012 added the ci:cloud-deploy Create or update a Cloud deployment label Jul 8, 2024
@peluja1012
Copy link
Contributor

/ci

1 similar comment
@patrykkopycinski
Copy link
Contributor Author

/ci

…aseByDefault and assistantModelEvaluation FF
@spong spong requested a review from a team as a code owner July 11, 2024 19:43
@spong spong added ci:cloud-redeploy Always create a new Cloud deployment and removed ci:cloud-deploy Create or update a Cloud deployment labels Jul 11, 2024
@spong
Copy link
Member

spong commented Jul 11, 2024

/ci

@elasticmachine
Copy link
Contributor

elasticmachine commented Jul 11, 2024

@@ -141,7 +141,7 @@
],
"id": "ml",
"size": {
"value": 1024,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik, this is no longer needed, with the autoscaling we have in place

@patrykkopycinski patrykkopycinski deleted the feat/esql-langgraph branch November 22, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:cloud-redeploy Always create a new Cloud deployment release_note:enhancement Team:Security Generative AI Security Generative AI v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.